//
//  LaunchNoNetController.m
//  gungunchou
//
//  Created by lyzbmacos3 on 2018/11/2.
//  Copyright © 2018年 xskj. All rights reserved.
//

#import "LaunchNoNetController.h"
#import "NetFailView.h"
#import "AppDelegate.h"

@interface LaunchNoNetController ()
@property (nonatomic, strong) NetFailView *netFailView;
@end

@implementation LaunchNoNetController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [NotificationCenter addObserver:self selector:@selector(refreshNet:) name:RefreshNetNotification object:nil];
    [self addErrorWeb];
}

- (void)addErrorWeb{
    self.netFailView = [[NSBundle mainBundle] loadNibNamed:@"NetFailView" owner:nil options:nil].firstObject;
    self.netFailView.frame = CGRectMake(0, StatusBarHeight, CGRectGetWidth(self.view.frame),CGRectGetHeight(self.view.frame));
    if (![CGNetManage isReachable]) {
        [self.netFailView showReasonLbl];
    }
    [self.view addSubview:self.netFailView];
}

- (void)refreshNet:(NSNotification *)notification
{
    if (![CGNetManage isReachable]) {
        return;
    }
    
    [[NSNotificationCenter defaultCenter] postNotificationName:App_Config_Thirds object:nil];
    [[NSNotificationCenter defaultCenter] postNotificationName:App_InitPage object:nil];
}
@end
